#导入该业务相关的UI类们
from page.page_index import PageIndex
from page.page_searchResult import PageSearchResult

#搜索业务
class SearchServer(object):

    def __init__(self,driver,base_url):
        self.driver=driver
        self.base_url=base_url

        #初始化相关的的页面对象们
        self.ui1=PageIndex(driver,base_url)
        self.ui2=PageSearchResult(driver,base_url)



    def service_search_001(self,d):
        #UI1页面的业务操作
        self.ui1.openUrl()
        self.ui1.inputSearchKw(d["kw"])
        self.ui1.clickSearchButton()
        siji=self.ui2.getFirstGoodsTitle()
        print(siji)
        return d["yuqi"] in siji

    def service_search_002(self,d):
        #UI1页面的业务操作
        self.ui1.openUrl()
        self.ui1.inputSearchKw(d["kw"])
        self.ui1.clickSearchButton()
        siji=self.ui2.getTipNull()
        return d["yuqi"]==siji

    def service_search_003(self,d):
        #UI1页面的业务操作
        self.ui1.openUrl()
        self.ui1.inputSearchKw(d["kw"])
        self.ui1.clickSearchButton()
        return self.ui2.isExistsNameInGoodsName(d["yuqi"])

    def service_search_004(self,d):
        #UI1页面的业务操作
        self.ui1.openUrl()
        self.ui1.inputSearchKw(d["kw"])
        self.ui1.clickSearchButton()
        siji=self.ui2.noGoods()
        return d["yuqi"] in siji

